home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 26 / AACD 26.iso / AACD / Programming / ace_gpl_release / src / lib / c / make_ILBMLib.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-10-04  |  1.9 KB  |  84 lines

  1. /*
  2. ** ACE run-time module to create/delete temporary ILBM.library.
  3. ** Copyright (C) 1998 David Benn
  4. ** 
  5. ** This program is free software; you can redistribute it and/or
  6. ** modify it under the terms of the GNU General Public License
  7. ** as published by the Free Software Foundation; either version 2
  8. ** of the License, or (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program; if not, write to the Free Software
  17. ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  18. **
  19. ** Author: David J Benn
  20. **   Date: 19th,21st,28th August 1994
  21. */
  22.  
  23. #include <exec/types.h>
  24. #include <libraries/dos.h>
  25.  
  26. #define    LIB_DIR     "ram:ILBMtmp"
  27. #define    ILBM_library     "ram:ILBMtmp/ilbm.library"
  28.  
  29. /* globals */
  30. BOOL    dir_created = FALSE;
  31. BOOL    lib_created = FALSE;
  32.  
  33. /* externals */
  34. extern    UBYTE ILBM_bytes[];
  35.  
  36. /* functions */
  37. void create_ILBMLib()
  38. {
  39. /*
  40. ** Create ILBM.library from a buffer
  41. ** containing its bytes. 
  42. */
  43. struct Lock *lock;
  44. struct FileHandle *fh;
  45.  
  46.     /*
  47.     ** Create ram:ILBMtmp and/or ILBM.library?
  48.     */
  49.     fh = (struct FileHandle *)Open("libs:ilbm.library",MODE_OLDFILE);
  50.     if (fh == NULL)
  51.     {
  52.         /*
  53.         ** Create ram:ILBMtmp. 
  54.         */
  55.         lock = (struct Lock *)CreateDir(LIB_DIR);
  56.         if (lock != NULL) 
  57.         {
  58.             UnLock(lock);
  59.             dir_created = TRUE;
  60.         }
  61.     
  62.         /*
  63.         ** Create ram:ILBMtmp/ILBM.library.
  64.         */
  65.         fh = (struct FileHandle *)Open(ILBM_library,MODE_NEWFILE);
  66.         if (fh != NULL)
  67.         {
  68.             Write(fh,ILBM_bytes,6924L);
  69.             Close(fh);
  70.             lib_created = TRUE;
  71.         }
  72.     }
  73. }
  74.  
  75. void remove_ILBMLib()
  76. {
  77. /*
  78. ** Delete temporary ILBM.library and/or ram:ILBMtmp.
  79. */
  80.  
  81.     if (lib_created) DeleteFile((STRPTR)ILBM_library);
  82.     if (dir_created) DeleteFile((STRPTR)LIB_DIR); 
  83. }
  84.